package com.bl.student.common.template;

import com.bl.student.common.enums.BizActionType;
import com.bl.student.common.enums.BizModule;
import lombok.AllArgsConstructor;
import lombok.Getter;

import static com.bl.student.common.enums.BizActionType.NEW;
import static com.bl.student.common.enums.BizModule.ACTIVITY_INVITED;
import static com.bl.student.common.enums.BizModule.NOTIFICATION;

/**
 * Created by yujingyi on 2017/9/9.
 */
@Getter
public class PushMessageTemplate {

    final static private String MESSAGE_TITLE = "画痨";

    private PushMessageType templateType;

    private String title;
    private String content;
    private BizModule module;
    private BizActionType action;

    public PushMessageTemplate(PushMessageType pushMessageType, String... templateArgs) {
        this.templateType = pushMessageType;
        this.content = String.format(this.templateType.getContent(), templateArgs);
        this.title = this.templateType.getTitle();
        this.module = this.templateType.getModule();
        this.action = this.templateType.getAction();
    }


    @Getter
    @AllArgsConstructor
    public enum PushMessageType {

        ACTIVITY_NEW_INVITED("活动邀请", MESSAGE_TITLE, "你收到一条活动邀请", ACTIVITY_INVITED, NEW),

        ACTIVITY_LOCKED("活动锁定", MESSAGE_TITLE, "你收到一条系统消息", NOTIFICATION, NEW),

        ACTIVITY_DELETED("活动删除", MESSAGE_TITLE, "你收到一条系统消息", NOTIFICATION, NEW),

        PENALTY_DEDUCTED("违约金扣除", MESSAGE_TITLE, "你收到一条系统消息", NOTIFICATION, NEW),

        ACTIVITY_DISSOLVED("活动解散", MESSAGE_TITLE,"你收到一条系统消息", NOTIFICATION, NEW),

        NEW_SYS_MESSAGE("有新系统消息", MESSAGE_TITLE, "你收到一条系统消息", NOTIFICATION, NEW),

        ORG_JOINED("成功加入组织", MESSAGE_TITLE, "你收到一条系统消息", NOTIFICATION, NEW),

        ORG_NEW_APPLY("有新组织申请", MESSAGE_TITLE, "你收到一条加入组织申请", NOTIFICATION, NEW),

        ACTIVITY_NEW_APPLY("画痨", MESSAGE_TITLE, "%s", NOTIFICATION, NEW);

        private String name;
        private String title;
        private String content;
        private BizModule module;
        private BizActionType action;
    }
}
